package com.study.jdk;

/**
 * Description:
 * User: tan
 * DateTime: 2018/2/9 16:38
 */
public class ThreadLocalTest {
    public static void main(String[] args) {
        ThreadLocal<Integer> integerThreadLocal = new ThreadLocal<>();
        ThreadLocal<String> stringThreadLocal = new ThreadLocal<>();

        integerThreadLocal.set(10);
        stringThreadLocal.set("string");

        int value = integerThreadLocal.get();
        String str = stringThreadLocal.get();


        Runnable runnable = new Runnable() {
            @Override
            public void run() {
                ThreadLocal<Integer> threadLocal = new ThreadLocal<>();
                threadLocal.set(10);

                ThreadLocal<String> threadLocal1 = new ThreadLocal<>();
                threadLocal1.set("jjj");
                threadLocal1.get();
            }
        };

        Thread thread = new Thread(runnable);
        thread.start();
    }
}
